package siga.visao_academico;

import java.sql.SQLException;
import javax.swing.JOptionPane;
import siga.banco.conexao;
import siga.navegadores.navegador;
import siga.visao_busca.buscaCurso;
import siga.visao_busca.buscaVer;
import siga.visao.index;
import siga.visao.verErros;

/**
 *
 * @author rafaelfrasson
 */
public class Dispensa_Disciplina_Tela extends javax.swing.JInternalFrame {
    Object[] JOopcoes = {"Sim","Não"};
    /** Creates new form Dispensa_Disciplina_Tela */
    public Dispensa_Disciplina_Tela() {
        initComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jpRaiz = new javax.swing.JPanel();
        jToolBar1 = new javax.swing.JToolBar();
        jButton2 = new javax.swing.JButton();
        jButton8 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jtfCod_acad = new javax.swing.JTextField();
        jtfDesc_acad = new javax.swing.JTextField();
        jbNovo = new javax.swing.JButton();
        jbAlterar = new javax.swing.JButton();
        jbCancelar = new javax.swing.JButton();
        jbSalvar = new javax.swing.JButton();
        jbExcluir = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jtfDisc_eq = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jtfInst_ensino = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jtfDisc_ensino = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jtfSituacao = new javax.swing.JComboBox();
        jtfNota = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jLabel9 = new javax.swing.JLabel();
        jtfTotal = new javax.swing.JLabel();
        jtfAno_sem = new javax.swing.JTextField();
        jtfCgHr = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jtfCgHrFP = new javax.swing.JTextField();
        jtfTotal1 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();

        setIconifiable(true);
        setMaximizable(true);
        setResizable(true);
        setTitle("Dispensa de Disciplinas");
        setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/centr_custo_16x16.png"))); // NOI18N

        jpRaiz.setName("jpRaiz"); // NOI18N

        jToolBar1.setFloatable(false);
        jToolBar1.setRollover(true);
        jToolBar1.setName("jToolBar1"); // NOI18N

        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/buscar_32x32.png"))); // NOI18N
        jButton2.setText("Acadêmico");
        jButton2.setToolTipText("Busca somente Acadêmicos");
        jButton2.setFocusable(false);
        jButton2.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jButton2.setName("jButton2"); // NOI18N
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        jToolBar1.add(jButton2);

        jButton8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/relatorio_32x32.png"))); // NOI18N
        jButton8.setText("Impressão");
        jButton8.setEnabled(false);
        jButton8.setFocusable(false);
        jButton8.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jButton8.setName("jButton8"); // NOI18N
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });
        jToolBar1.add(jButton8);

        jLabel1.setText("Acadêmico:");
        jLabel1.setName("jLabel1"); // NOI18N

        jtfCod_acad.setEnabled(false);
        jtfCod_acad.setName("jtfCod_acad"); // NOI18N

        jtfDesc_acad.setEnabled(false);
        jtfDesc_acad.setName("jtfDesc_acad"); // NOI18N

        jbNovo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/novo_32x32.png"))); // NOI18N
        jbNovo.setText("Novo");
        jbNovo.setEnabled(false);
        jbNovo.setName("jbNovo"); // NOI18N
        jbNovo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbNovoActionPerformed(evt);
            }
        });

        jbAlterar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/editar_32x32.png"))); // NOI18N
        jbAlterar.setText("Alterar");
        jbAlterar.setEnabled(false);
        jbAlterar.setName("jbAlterar"); // NOI18N
        jbAlterar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbAlterarActionPerformed(evt);
            }
        });

        jbCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/cancelar_32x32.png"))); // NOI18N
        jbCancelar.setText("Cancelar");
        jbCancelar.setEnabled(false);
        jbCancelar.setName("jbCancelar"); // NOI18N
        jbCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbCancelarActionPerformed(evt);
            }
        });

        jbSalvar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/salvar_32x32.png"))); // NOI18N
        jbSalvar.setText("Salvar");
        jbSalvar.setEnabled(false);
        jbSalvar.setName("jbSalvar"); // NOI18N
        jbSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbSalvarActionPerformed(evt);
            }
        });

        jbExcluir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/remover_32x32.png"))); // NOI18N
        jbExcluir.setText("Remover");
        jbExcluir.setEnabled(false);
        jbExcluir.setName("jbExcluir"); // NOI18N
        jbExcluir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbExcluirActionPerformed(evt);
            }
        });

        jLabel2.setText("Disciplina para Equivalência:");
        jLabel2.setName("jLabel2"); // NOI18N

        jtfDisc_eq.setEnabled(false);
        jtfDisc_eq.setName("jtfDisc_eq"); // NOI18N

        jLabel3.setText("Instituição de onde vem:");
        jLabel3.setName("jLabel3"); // NOI18N

        jtfInst_ensino.setEnabled(false);
        jtfInst_ensino.setName("jtfInst_ensino"); // NOI18N

        jLabel4.setText("Disciplina da Instituição:");
        jLabel4.setName("jLabel4"); // NOI18N

        jtfDisc_ensino.setEnabled(false);
        jtfDisc_ensino.setName("jtfDisc_ensino"); // NOI18N

        jLabel5.setText("Ano/Semestre:");
        jLabel5.setName("jLabel5"); // NOI18N

        jLabel6.setText("Carga Hr.:");
        jLabel6.setName("jLabel6"); // NOI18N

        jLabel7.setText("Nota:");
        jLabel7.setName("jLabel7"); // NOI18N

        jLabel8.setText("Situação:");
        jLabel8.setName("jLabel8"); // NOI18N

        jtfSituacao.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Deferido(a)", "Indeferido(a)", "Dispensado(a)", "Processo em Aberto", "Processo em Aberto (Entrevista Pessoa)" }));
        jtfSituacao.setEnabled(false);
        jtfSituacao.setName("jtfSituacao"); // NOI18N

        jtfNota.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jtfNota.setEnabled(false);
        jtfNota.setName("jtfNota"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Código", "Disciplina", "Carga HR.", "Instituição", "Disc. Inst.", "Ano/Sem", "Carga Hr.", "Nota", "Situação"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable1.setName("jTable1"); // NOI18N
        jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTable1MouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jTable1);
        jTable1.getColumnModel().getColumn(0).setMinWidth(60);
        jTable1.getColumnModel().getColumn(0).setPreferredWidth(60);
        jTable1.getColumnModel().getColumn(0).setMaxWidth(60);
        jTable1.getColumnModel().getColumn(2).setMinWidth(70);
        jTable1.getColumnModel().getColumn(2).setPreferredWidth(70);
        jTable1.getColumnModel().getColumn(2).setMaxWidth(70);
        jTable1.getColumnModel().getColumn(3).setMinWidth(80);
        jTable1.getColumnModel().getColumn(3).setPreferredWidth(80);
        jTable1.getColumnModel().getColumn(3).setMaxWidth(80);
        jTable1.getColumnModel().getColumn(5).setMinWidth(70);
        jTable1.getColumnModel().getColumn(5).setPreferredWidth(70);
        jTable1.getColumnModel().getColumn(5).setMaxWidth(70);
        jTable1.getColumnModel().getColumn(6).setMinWidth(70);
        jTable1.getColumnModel().getColumn(6).setPreferredWidth(70);
        jTable1.getColumnModel().getColumn(6).setMaxWidth(70);
        jTable1.getColumnModel().getColumn(7).setMinWidth(60);
        jTable1.getColumnModel().getColumn(7).setPreferredWidth(60);
        jTable1.getColumnModel().getColumn(7).setMaxWidth(60);
        jTable1.getColumnModel().getColumn(8).setMinWidth(90);
        jTable1.getColumnModel().getColumn(8).setPreferredWidth(90);
        jTable1.getColumnModel().getColumn(8).setMaxWidth(90);

        jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel9.setText("Carga Hr. Total:");
        jLabel9.setName("jLabel9"); // NOI18N

        jtfTotal.setFont(new java.awt.Font("DejaVu Sans", 1, 13));
        jtfTotal.setForeground(new java.awt.Color(173, 8, 8));
        jtfTotal.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jtfTotal.setText("0");
        jtfTotal.setName("jtfTotal"); // NOI18N

        jtfAno_sem.setEnabled(false);
        jtfAno_sem.setName("jtfAno_sem"); // NOI18N

        jtfCgHr.setEnabled(false);
        jtfCgHr.setName("jtfCgHr"); // NOI18N

        jLabel10.setText("Carga Hr.:");
        jLabel10.setName("jLabel10"); // NOI18N

        jtfCgHrFP.setEnabled(false);
        jtfCgHrFP.setName("jtfCgHrFP"); // NOI18N

        jtfTotal1.setFont(new java.awt.Font("DejaVu Sans", 1, 13));
        jtfTotal1.setForeground(new java.awt.Color(173, 8, 8));
        jtfTotal1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jtfTotal1.setText("0");
        jtfTotal1.setName("jtfTotal1"); // NOI18N

        jLabel11.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel11.setText("Carga Hr. Total:");
        jLabel11.setName("jLabel11"); // NOI18N

        javax.swing.GroupLayout jpRaizLayout = new javax.swing.GroupLayout(jpRaiz);
        jpRaiz.setLayout(jpRaizLayout);
        jpRaizLayout.setHorizontalGroup(
            jpRaizLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 1119, Short.MAX_VALUE)
            .addGroup(jpRaizLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addContainerGap(1027, Short.MAX_VALUE))
            .addGroup(jpRaizLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jtfCod_acad, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtfDesc_acad, javax.swing.GroupLayout.DEFAULT_SIZE, 985, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(jpRaizLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jbNovo)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbAlterar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbCancelar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbSalvar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jbExcluir)
                .addContainerGap(588, Short.MAX_VALUE))
            .addGroup(jpRaizLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addContainerGap(913, Short.MAX_VALUE))
            .addGroup(jpRaizLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jtfDisc_eq, javax.swing.GroupLayout.DEFAULT_SIZE, 1095, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(jpRaizLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel4)
                .addContainerGap(942, Short.MAX_VALUE))
            .addGroup(jpRaizLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jtfDisc_ensino, javax.swing.GroupLayout.DEFAULT_SIZE, 1095, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(jpRaizLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpRaizLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jtfAno_sem, javax.swing.GroupLayout.DEFAULT_SIZE, 104, Short.MAX_VALUE)
                    .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpRaizLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6)
                    .addComponent(jtfCgHr, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpRaizLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jtfNota, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpRaizLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jtfSituacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8))
                .addGap(484, 484, 484))
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 1119, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jpRaizLayout.createSequentialGroup()
                .addGap(154, 154, 154)
                .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtfTotal1, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 329, Short.MAX_VALUE)
                .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtfTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(158, 158, 158))
            .addGroup(jpRaizLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpRaizLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel10)
                    .addComponent(jtfCgHrFP, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jpRaizLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addComponent(jtfInst_ensino, javax.swing.GroupLayout.PREFERRED_SIZE, 289, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(728, Short.MAX_VALUE))
        );
        jpRaizLayout.setVerticalGroup(
            jpRaizLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpRaizLayout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpRaizLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtfCod_acad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jtfDesc_acad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jpRaizLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jbNovo)
                    .addComponent(jbAlterar)
                    .addComponent(jbCancelar)
                    .addComponent(jbSalvar)
                    .addComponent(jbExcluir))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtfDisc_eq, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(12, 12, 12)
                .addGroup(jpRaizLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jpRaizLayout.createSequentialGroup()
                        .addComponent(jLabel10)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtfCgHrFP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jpRaizLayout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtfInst_ensino, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtfDisc_ensino, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jpRaizLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jpRaizLayout.createSequentialGroup()
                        .addGroup(jpRaizLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(jLabel7)
                            .addComponent(jLabel5))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jpRaizLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jtfAno_sem, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jtfCgHr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jtfNota, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jpRaizLayout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtfSituacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 190, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpRaizLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtfTotal)
                    .addComponent(jLabel9)
                    .addComponent(jtfTotal1)
                    .addComponent(jLabel11))
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jpRaiz, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jpRaiz, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        buscaVer.setTipo("Unimestre");
        buscaVer bv = new buscaVer(null,true);
        bv.setLocation((index.tela.width-bv.getWidth())/2, (index.tela.height-bv.getHeight())/2);
        bv.setVisible(true);
        if(buscaVer.isConfirmaBusca()){
            jtfCod_acad.setText(index.LRpessoa.get(0).toString());
            jtfDesc_acad.setText(index.LRpessoa.get(1).toString());
            carrega_tabela();
            jbNovo.setEnabled(true);
            jButton8.setEnabled(true);
        }
        index.LRpessoa.add(0, "");
        index.LRpessoa.add(1, "");
}//GEN-LAST:event_jButton2ActionPerformed

    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
         index.LRcurso.clear();
        buscaCurso bc = new buscaCurso(null,true);
        bc.setLocation((index.tela.width-bc.getWidth())/2, (index.tela.height-bc.getHeight())/2);
        bc.setVisible(true);
        if(buscaCurso.isConfirmaCurso()){
            if(!jtfCod_acad.getText().equals("")){
                navegador.URL(index.relatorio+"relatorios/relatorio_dispensa_disciplina.php?cod_emp="+index.cod_emp+"&curso="+index.LRcurso.get(0)+"&cod_pessoa="+jtfCod_acad.getText()+"&desc_pessoa="+jtfDesc_acad.getText());
            }else{
                JOptionPane.showMessageDialog(null, "Selecione um Acadêmico.","Informação do Sistema",JOptionPane.INFORMATION_MESSAGE);
            }
            index.LRcurso.clear();
        }


}//GEN-LAST:event_jButton8ActionPerformed

    private void jbNovoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbNovoActionPerformed
        clear_campos();
        campos();
        jTable1.setEnabled(false);
        jbCancelar.setEnabled(true);
        jbSalvar.setEnabled(true);
}//GEN-LAST:event_jbNovoActionPerformed

    private void jbAlterarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbAlterarActionPerformed
        jbSalvar.setEnabled(true);
        jbCancelar.setEnabled(true);
        jbNovo.setEnabled(false);
        jbAlterar.setEnabled(false);
        jbExcluir.setEnabled(false);
        jTable1.setEnabled(false);
        campos();
}//GEN-LAST:event_jbAlterarActionPerformed

    private void jbCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbCancelarActionPerformed
        jbSalvar.setEnabled(false);
        jbCancelar.setEnabled(false);
        jbNovo.setEnabled(true);
        jbAlterar.setEnabled(false);
        jbExcluir.setEnabled(false);
        jTable1.setEnabled(true);
        campos();
        clear_campos();
        carrega_tabela();
}//GEN-LAST:event_jbCancelarActionPerformed

    private void jbSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbSalvarActionPerformed
        if(!jtfDisc_eq.getText().equals("") && !jtfInst_ensino.getText().equals("") && !jtfDisc_ensino.getText().equals("") && !jtfAno_sem.getText().equals("    / ") && !jtfCgHr.getText().equals("") && !jtfNota.getText().equals("")){
            if(jbNovo.isEnabled()){
                conexao.Inserir("insert into grade_dispenca (cod_emp,equiv_fucap,inst_ensino, disc_ensino,ano_sem, cg_hr,cg_hr_fucap,nota,cd_aluno,nm_aluno,sit_disp) " +
                            " values (" + index.cod_emp + ",\"" + jtfDisc_eq.getText() + "\",\"" + jtfInst_ensino.getText() + "\",\"" + jtfDisc_ensino.getText() + "\",\"" + jtfAno_sem.getText() + "\"," + jtfCgHr.getText() + "," + jtfCgHrFP.getText() + ",\"" + jtfNota.getText().replace(",", ".") + "\"," + jtfCod_acad.getText() + ", \"" + jtfDesc_acad.getText() + "\",\"" + jtfSituacao.getSelectedItem() + "\")");
                
            }else{
                conexao.Inserir("replace into grade_dispenca (codigo, cod_emp,equiv_fucap,inst_ensino, disc_ensino,ano_sem,cg_hr,cg_hr_fucap,nota,cd_aluno,nm_aluno,sit_disp) " +
                            " values (" + jTable1.getValueAt(jTable1.getSelectedRow(), 0).toString() +"," + index.cod_emp + ",\"" + jtfDisc_eq.getText() + "\",\"" + jtfInst_ensino.getText() + "\",\"" + jtfDisc_ensino.getText() + "\",\"" + jtfAno_sem.getText() + "\"," + jtfCgHr.getText() + "," + jtfCgHrFP.getText() + ",\"" + jtfNota.getText().replace(",", ".") + "\"," + jtfCod_acad.getText() + ", \"" + jtfDesc_acad.getText() + "\", \"" + jtfSituacao.getSelectedItem().toString() + "\")");
                
            }
            jbSalvar.setEnabled(false);
            jbCancelar.setEnabled(false);
            jbNovo.setEnabled(true);
            jbAlterar.setEnabled(false);
            jTable1.setEnabled(true);
            carrega_tabela();
            campos();
            clear_campos();
        }else{
            JOptionPane.showMessageDialog(null, "Todos os campos devem estar preenchidos.", "Informação do Sistema",JOptionPane.ERROR_MESSAGE);
        }
}//GEN-LAST:event_jbSalvarActionPerformed

    private void jbExcluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbExcluirActionPerformed
        if (JOptionPane.showOptionDialog(null, "Deseja remover esta Dispensa de Disciplina?", "Removendo Dispensa de Disciplina", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, JOopcoes, JOopcoes[0]) == JOptionPane.YES_OPTION) {
            try {
                conexao.stm.executeUpdate("delete from grade_dispenca where cd_aluno=" + jtfCod_acad.getText() + " and codigo="+jTable1.getValueAt(jTable1.getSelectedRow(), 0).toString()+" and cod_emp=" + index.cod_emp);

                jbSalvar.setEnabled(false);
                jbCancelar.setEnabled(false);
                jbNovo.setEnabled(true);
                jbAlterar.setEnabled(false);

                clear_campos();
                carrega_tabela();
            } catch (SQLException ex) {
                verErros.setErro(ex.getMessage());
            }
        }
}//GEN-LAST:event_jbExcluirActionPerformed

    private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked
         if(evt.getClickCount() == 2){
                if(jbAlterar.isEnabled() || jbNovo.isEnabled()){
                    jtfDisc_eq.setText(jTable1.getValueAt(jTable1.getSelectedRow(), 1).toString());
                    jtfCgHrFP.setText(jTable1.getValueAt(jTable1.getSelectedRow(), 2).toString());
                    jtfInst_ensino.setText(jTable1.getValueAt(jTable1.getSelectedRow(), 3).toString());
                    jtfDisc_ensino.setText(jTable1.getValueAt(jTable1.getSelectedRow(), 4).toString());
                    jtfAno_sem.setText(jTable1.getValueAt(jTable1.getSelectedRow(), 5).toString());
                    jtfCgHr.setText(jTable1.getValueAt(jTable1.getSelectedRow(), 6).toString());
                    jtfNota.setText(jTable1.getValueAt(jTable1.getSelectedRow(), 7).toString());
                    String sit = (jTable1.getValueAt(jTable1.getSelectedRow(), 8).toString().equals("Deferido") || jTable1.getValueAt(jTable1.getSelectedRow(), 7).toString().equals("Deferida"))?"Deferido(a)":(jTable1.getValueAt(jTable1.getSelectedRow(), 7).toString().equals("Indeferido") || jTable1.getValueAt(jTable1.getSelectedRow(), 7).toString().equals("Indeferida"))?"Indeferido(a)":"";
                    jtfSituacao.setSelectedItem(sit);

                    jbNovo.setEnabled(false);
                    jbAlterar.setEnabled(true);
                    jbExcluir.setEnabled(true);
                }

        }
    }//GEN-LAST:event_jTable1MouseClicked

    private void carrega_tabela(){
        int i = jTable1.getRowCount();
        int conta=0;
        int conta2=0;
        javax.swing.table.DefaultTableModel jtm = (javax.swing.table.DefaultTableModel)jTable1.getModel();
        for(int x=(i-1);x>=0; --x ){
            jtm.removeRow(x);
        }
        try {
            conexao.Query("select * from grade_dispenca where cd_aluno="+jtfCod_acad.getText()+" and cod_emp="+index.cod_emp+" order by equiv_fucap");
            while (conexao.rs.next()) {
                conta+=conexao.rs.getInt("cg_hr");
                conta2+=conexao.rs.getInt("cg_hr_fucap");
                jtm.addRow(new Object[]{conexao.rs.getString("codigo"),conexao.rs.getString("equiv_fucap"),conexao.rs.getString("cg_hr_fucap"),conexao.rs.getString("inst_ensino"),conexao.rs.getString("disc_ensino"),conexao.rs.getString("ano_sem"),conexao.rs.getString("cg_hr"),conexao.rs.getString("nota").replace(".", ","),conexao.rs.getString("sit_disp")});
            }
            jtfTotal.setText(""+conta);
            jtfTotal1.setText(""+conta2);
        } catch (SQLException ex) {
            verErros.setErro(ex.getMessage());
        }
    }

    private void  campos(){
        jtfSituacao.setEnabled(!jtfDisc_eq.isEnabled());
        jtfNota.setEnabled(!jtfDisc_eq.isEnabled());
        jtfAno_sem.setEnabled(!jtfDisc_eq.isEnabled());
        jtfCgHr.setEnabled(!jtfDisc_eq.isEnabled());
        jtfCgHrFP.setEnabled(!jtfDisc_eq.isEnabled());
        jtfDisc_ensino.setEnabled(!jtfDisc_eq.isEnabled());
        jtfInst_ensino.setEnabled(!jtfDisc_eq.isEnabled());
        jtfDisc_eq.setEnabled(!jtfDisc_eq.isEnabled());
    }

    private void clear_campos(){
        jtfSituacao.setSelectedItem("Deferido(a)");
        jtfNota.setText("");
        jtfAno_sem.setText("");
        jtfCgHr.setText("");
        jtfCgHrFP.setText("");
        jtfDisc_ensino.setText("");
        jtfInst_ensino.setText("");
        jtfDisc_eq.setText("");
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton8;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JButton jbAlterar;
    private javax.swing.JButton jbCancelar;
    private javax.swing.JButton jbExcluir;
    private javax.swing.JButton jbNovo;
    private javax.swing.JButton jbSalvar;
    private javax.swing.JPanel jpRaiz;
    private javax.swing.JTextField jtfAno_sem;
    private javax.swing.JTextField jtfCgHr;
    private javax.swing.JTextField jtfCgHrFP;
    private javax.swing.JTextField jtfCod_acad;
    private javax.swing.JTextField jtfDesc_acad;
    private javax.swing.JTextField jtfDisc_ensino;
    private javax.swing.JTextField jtfDisc_eq;
    private javax.swing.JTextField jtfInst_ensino;
    private javax.swing.JTextField jtfNota;
    private javax.swing.JComboBox jtfSituacao;
    private javax.swing.JLabel jtfTotal;
    private javax.swing.JLabel jtfTotal1;
    // End of variables declaration//GEN-END:variables

}
